package student

import (
	"fmt"
)

// obb 演示函数
func OBBDemo() {
	var zhangsan person
	zhangsan.name = "张三"

	var lisi *person
	//fmt.Println("之前",lisi.name)
	lisi = &zhangsan
	fmt.Println("之后", lisi.name)
	zhangsan.name = "大张三"
	fmt.Println("改了之后", lisi.name)
	var wangwu *person
	wangwu = &zhangsan
	fmt.Println("改了之后wangwu", wangwu.name)
	zhangsan.fahongbao(8, lisi)
}

// 发红包，额度，收红包的切片
func (s *person) fahongbao(edu float32, mubiao ...*person) {
	s.money = s.money - edu*float32(len(mubiao))
	for i := 0; i < len(mubiao); i++ {
		mubiao[i].money = mubiao[i].money + edu
	}
}

// 转账， to 接收的人，edu 转账的额度
func (p *person) zhuanzhang(to *person, edu float32) bool {

	p.money = p.money - edu - edu*0.01
	to.money += edu - edu*0.01
	return true
}
